package chapter02

object Test19_Array5 {
  def main(args: Array[String]): Unit = {
    val yidong= Array(
      1340, 1341, 1342, 1343, 1344, 1345, 1346,
      1347, 1348, 135, 136, 137, 138, 139, 150,
      151, 152, 157, 158, 159, 182, 183, 184, 187, 188, 178, 147, 1705)
    val liantong = Array(130, 131, 132, 155, 156, 185, 186, 176, 145, 1709)
    val dianxin = Array(133, 1349, 153, 180, 181, 189, 1700, 177)
    //接收输入
    println("请输入电话号码：")
    val phone = scala.io.StdIn.readLine()
    val subThree = phone.substring(0,3).toInt
    val subFour = phone.substring(0,4).toInt
    if(phone.length!=11){
      println("输入号码有误")
    }else if(yidong.contains(subThree)||yidong.contains(subFour)){
      println("号码的运营商为移动")
    }else if(liantong.contains(subThree)||liantong.contains(subFour)){
      println("号码的运营商为联通")
    }else if(dianxin.contains(subThree)||dianxin.contains(subFour)){
      println("号码的运营商为电信")
    }else{
      println("未查询到运营商")
    }
  }
}
